package per.ace.gson.controller;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import per.ace.gson.entity.User;

/**
 * @program: ace-json-starter
 * @description: user web
 * @author: ace
 * @Date: 2020-03-28 17:43
 */
@RestController
@RequestMapping("user")
public class UserController {

    @GetMapping
    public String getUser(){
        Gson gson = new GsonBuilder().create();

        User user = new User(12L,"alex");
        System.out.println(user.toString());
        return gson.toJson(user);
    }

    @GetMapping("vo")
    public User getUserVO(){
        User user = new User(12L,"alex");
        System.out.println(user.toString());
        return user;
    }
}
